package com.groupbuying.admin.utils.apiresult;

/**
 * @anthor  cuich
 * @date    2019/7/23 11:14 AM
 * @company 蒙泰互联网公司
 * @des     代理商接口请求返回定义
 **/

public enum AgentApiResultCode{
    //通用提示
    FAILURE(0, "请求失败"),
    FAILURE_REGISTER(0, "注册失败"),
    OPRFAILURE(0, "操作失败"),
    SUCCESS(1, "请求成功"),
    OPRSUCCESS(1, "操作成功"),
    OUTLOGIN(2, "未登录"),
    ILLEGAL(3, "非法登录"),

    //统一错误码0
    FAILURE_NAMENULL(0, "用户名为空"),
    FAILURE_NULL(0, "用户名为空"),
    FAILURE_NAMEEXIST(0, "用户名已存在"),
    FAILURE_USER_EXIST(0, "此账号已存在"),
    FAILURE_AGENTNAMEEXIST(0, "代理商已存在"),
    FAILURE_AGENT_NO_EXIST(0, "代理商账号已存在"),
    FAILURE_USERUNEXIST(0, "用户名不存在"),
    FAILURE_NAMEFAIL(0, "用户名格式不正确"),
    FAILURE_NAMEHASCHINESE(0, "用户名格式不正确，含有汉字"),
    FAILURE_LEADERNAMEFAIL(0, "代理商名字格式不正确"),
    FAILURE_PASSNULL(0, "密码为空"),
    REAPEATREGIST(0, "注册中，请勿重复操作"),
    PARAMNULL(0, "请求参数为空"),
    MOBILEFAIL(0, "手机号格式不正确"),
    PARAMERROR(0, "请求参数不正确"),
    SENDCODEFAILURE(0,"发送验证码失败"),
    VERIFICATIONCODEERROR(0,"验证码不正确"),
    PASSWORDERROR(0,"密码错误"),
    OLDPASSWORDERROR(0,"输入旧密码错误"),
    FILENOTEXISTS(0,"文件不存在"),
    SYSCODENOTEXISTS(0,"系统编号不存在"),
    APPLICATIONISNULL(0,"应用名称为空"),
    OSSCATELOGISNULL(0,"OSS目录为空"),
    COMPANYINFO_NOTEXISTS(0,"企业信息不完善"),
    COMPANYQUALIFICATION_NOTEXISTS(0,"企业资质信息不完善"),
    STORECAPITALVIRTUALACCOUNT_NOTEXISTS(0,"企业资金账户不完善"),

    //统一成功码1
    SUCCESS_REGISTER(1, "注册成功"),
    SUCCESS_LOGIN(1, "登录成功"),
    SUCCESS_SET(1, "设置成功"),
    SUCCESS_GETCODE(1, "验证码已发送至您手机");


    /**
     * 编码
     */
    private Integer code;
    /**
     * 消息
     */
    private String message;


    AgentApiResultCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }


    public Integer code() {
        return this.code;
    }


    public String message() {
        return this.message;
    }


    public static Integer getCode(String name) {
        for (AgentApiResultCode resultCode : AgentApiResultCode.values()) {
            if (resultCode.name().equals(name)) {
                return resultCode.code;
            }
        }
        return null;
    }


    public static String getMessage(String name) {
        for (AgentApiResultCode resultCode : AgentApiResultCode.values()) {
            if (resultCode.name().equals(name)) {
                return resultCode.message;
            }
        }
        return name;
    }


    @Override
    public String toString() {
        return this.name();
    }

}

